<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title></title>
  </head>
  <body>
    <div id="app">
      <h3>基础用法：</h3>
      <ul>
        <li v-for="item in items">{{ item.message }}</li>
      </ul>

      <h3>基础用法+索引+获取父级作用域参数：</h3>
      <ul>
        <li v-for="(item, index) in items">
          {{ parentMessage }} - {{ index }} - {{ item.message }}
        </li>
      </ul>

      <h3>解构用法：</h3>
      <ul>
        <li v-for="{ message } in items">{{ message }}</li>
      </ul>

      <h3>解构用法+索引：</h3>
      <ul>
        <li v-for="({ message }, index) in items">{{ message }} {{ index }}</li>
      </ul>

      <h3>支持 of 更语义化：</h3>
      <ul>
        <li v-for="item of items">{{ item.message }}</li>
      </ul>
    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
      const { createApp, ref } = Vue;

      createApp({
        setup() {
          const parentMessage = ref("Parent");
          const items = ref([{ message: "Foo" }, { message: "Bar" }]);

          return {
            parentMessage,
            items,
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
